package ase.assignment.sts.rmi.server;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import ase.assignment.sts.api.StockHandler;
import ase.assignment.sts.beans.StockAssertEntity;
import ase.assignment.sts.beans.StockQuoteEntity;
import ase.assignment.sts.db.impl.HandlerFactoryJDBCImpl;

public class StockHandlerRMIServerImpl extends UnicastRemoteObject implements
		StockHandler {

	protected StockHandlerRMIServerImpl() throws RemoteException {
		super();
		// TODO Auto-generated constructor stub
	}

	private static final long serialVersionUID = 3930456185990547554L;

	private StockHandler getHandler() throws RemoteException {
		return new HandlerFactoryJDBCImpl().getStockHandler();
	}

	public void create(StockAssertEntity stock) throws RemoteException {
		getHandler().create(stock);
	}

	public void delete(int stockId) throws RemoteException {
		getHandler().delete(stockId);
	}

	public StockAssertEntity findById(int stockId) throws RemoteException {
		return getHandler().findById(stockId);
	}

	public StockAssertEntity[] getAllStocks(int porId) throws RemoteException {
		return getHandler().getAllStocks(porId);
	}

	public StockQuoteEntity getCurrentPrice(int stockId) throws RemoteException {
		return getHandler().getCurrentPrice(stockId);
	}

	public void update(StockAssertEntity stock) throws RemoteException {
		getHandler().update(stock);
	}

}
